package com.magina.antiPro.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class CalendarUtil {
    /**
     * schendler 项目 当前日期减一天 距离 今年的1月1号 的天数
     * @return
     */
    private static int getYTDDays(){
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR, -24);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR,calendar.get(Calendar.YEAR));
        cal.set(Calendar.MONTH, 0);
        cal.set(Calendar.DAY_OF_MONTH,1);
        return calendar.get(Calendar.DAY_OF_YEAR) - cal.get(Calendar.DAY_OF_YEAR);
    }
    /**
     * schendler 项目 当前日期的当月1号 距离 今年的1月1号 的天数
     * @return
     */
    public static int getMTDDays(){
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR,calendar.get(Calendar.YEAR));
        cal.set(Calendar.MONTH, 0);
        cal.set(Calendar.DAY_OF_MONTH,1);
        return calendar.get(Calendar.DAY_OF_YEAR) - cal.get(Calendar.DAY_OF_YEAR);
    }
}
